#pragma once
#include <nodes\SpriteNode.h>
#include "Vector.h"
#include "Constants.h"

class Laser : public ds::SpriteNode {

public:
	Laser() : ds::SpriteNode("Laser","TexturesMaterial") , m_Running(false) , m_XPos(0.0f) ,m_Delay(5.0f) , m_Timer(0.0f) {}
	~Laser(void);
	void loadContent( ds::ResManager& resourceManager );
	void update(float elapsed);
	bool isRunning() const {
		return m_Running;
	}
	int getRow() const {
		if ( !m_Running ) {
			return -1;
		}
		int r = ((int)m_XPos-START_X)/36;
		return r;
	}
	void reset() {
		m_Timer = 0.0f;
		for ( int i = 0; i < 7; ++i ) {
			ds::SHandle& sh = m_Sprites->get(i);
			setVisible(sh,false);
		}
		m_Running = false;
		if ( gEngine->getAudioManager().isPlaying("Laser")) {
			gEngine->getAudioManager().stop("Laser");
		}
	}
private:
	Vector<ds::SHandle>* m_Sprites;
	float m_XPos;
	bool m_Running;
	float m_Delay;
	float m_Timer;
};

